package com.ruoyi.project.simple.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.simple.domain.SplSimpleNorm;
import com.ruoyi.project.simple.service.ISplSimpleNormService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 样品指标Controller
 * 
 * @author ruoyi
 * @date 2020-08-11
 */
@RestController
@RequestMapping("/simple/norm")
public class SplSimpleNormController extends BaseController
{
    @Autowired
    private ISplSimpleNormService splSimpleNormService;

    /**
     * 查询样品指标列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SplSimpleNorm splSimpleNorm)
    {
        startPage();
        List<SplSimpleNorm> list = splSimpleNormService.selectSplSimpleNormList(splSimpleNorm);
        return getDataTable(list);
    }

    /**
     * 导出样品指标列表
     */
    @Log(title = "样品指标", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SplSimpleNorm splSimpleNorm)
    {
        List<SplSimpleNorm> list = splSimpleNormService.selectSplSimpleNormList(splSimpleNorm);
        ExcelUtil<SplSimpleNorm> util = new ExcelUtil<SplSimpleNorm>(SplSimpleNorm.class);
        return util.exportExcel(list, "norm");
    }

    /**
     * 获取样品指标详细信息
     */
    @PreAuthorize("@ss.hasPermi('simple:norm:query')")
    @GetMapping(value = "/{simpleNormId}")
    public AjaxResult getInfo(@PathVariable("simpleNormId") Integer simpleNormId)
    {
        return AjaxResult.success(splSimpleNormService.selectSplSimpleNormById(simpleNormId));
    }

    /**
     * 新增样品指标
     */
    @PreAuthorize("@ss.hasPermi('simple:norm:add')")
    @Log(title = "样品指标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SplSimpleNorm splSimpleNorm)
    {
        return toAjax(splSimpleNormService.insertSplSimpleNorm(splSimpleNorm));
    }

    /**
     * 修改样品指标
     */
    @PreAuthorize("@ss.hasPermi('simple:norm:edit')")
    @Log(title = "样品指标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SplSimpleNorm splSimpleNorm)
    {
        return toAjax(splSimpleNormService.updateSplSimpleNorm(splSimpleNorm));
    }

    /**
     * 删除样品指标
     */
    @PreAuthorize("@ss.hasPermi('simple:norm:remove')")
    @Log(title = "样品指标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{simpleNormIds}")
    public AjaxResult remove(@PathVariable Integer[] simpleNormIds)
    {
        return toAjax(splSimpleNormService.deleteSplSimpleNormByIds(simpleNormIds));
    }
}
